# Definition for singly-linked list.
class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next
# class Solution:
#     def reorderList(self, head) -> None:
#         """
#         Do not return anything, modify head in-place instead.
#         """
#         # 寻找链表中间节点
#         slow = head
#         fast = head
#
#         while fast and fast.next:
#             slow = slow.next
#             fast = fast.next.next
#
#         # 链表反转
#         pre = None
#         cur = slow
#         while cur:
#             temp = cur.next
#             cur.next = pre
#             pre = cur
#             cur = temp
#
#         middle = slow
#         head1 = head
#         head2 = pre
#
#         while head2 != middle:
#             temp1 = head1.next
#             temp2 = head2.next
#             head1.next = head2
#             head2.next = temp1
#             head2 = temp2
#             head1 = temp1

# class Solution:
#     def deleteDuplicates(self, head):
#
#         if not head: return head
#
#         cur = head
#         while cur.next:
#             if cur.val == cur.next.val:
#                 cur.next = cur.next.next
#             else:
#                 cur = cur.next
#         return head


import pandas as pd

# # 创建字典，其中的键是列名，值是数据列表
# data = {
#     'Column1': [1, "a", 3, 4],
#     'Column2': ['a', 'b', 'c', 'd'],
#     'Column3': [True, False, True, False]
# }
#
# # 使用字典创建DataFrame
# df = pd.DataFrame(data)


class Solution:
    def merge(self, intervals):
        intervals.sort()
        n = len(intervals)

        # 表示数组索引
        cnt = 1

        # 表示需要对比的次数
        i = 1
        while i < n:
            if intervals[cnt][0] <= intervals[cnt-1][-1]:
                intervals[cnt] = [intervals[cnt-1][0], max(intervals[cnt][1], intervals[cnt-1][1])]
                del intervals[cnt - 1]
            else:
                cnt += 1
            i += 1

        return intervals
